<script setup>
  import { ossImg } from "@/utils/utils";
  import { onMounted } from "vue";

  const emits = defineEmits(['close'])
  const emdlz = getApp().emdlz2

  onMounted(() => {
    emdlz('track','event','Oreo_eggy_tbpswd_page','view','tips_tb','');
  })

  const handleCloseModal = () => {
    emdlz('track','event','Oreo_eggy_tbpswd_page','click','close_tbtips','');
    emits('close')
  }

  const onCopy = () => {
    emdlz('track','event','Oreo_eggy_tbpswd_page','click','copy_tbpswd','');
    uni.setClipboardData({
      data: `787￥ CZ0000 ZoPnWKxvsAp￥ https://m.tb.cn/h.5zpweRJ`,
      success: () => {
        uni.hideToast()
        setTimeout(() => {
          uni.showToast({
            title: '淘口令已复制，请打开手机天猫',
            icon: 'none',
            duration: 2400
          })
        }, 50)
      },
      fail: (err) => {
        console.log(err)
      }
    })
  }
</script>

<template>
  <view class="result-modal">
    <view class="dialog-body">
      <image
        class="w-42px h-42px absolute top-78px right-18px"
        :src="ossImg('others/cloudsample/dialog/close.png')"
        @click.stop="handleCloseModal"
      ></image>
      <image
        class="result-image"
        :src="ossImg(`others/cloudsample/dialog/go_buy.png`)"
      ></image>
      <image
        class="back-btn"
        :src="ossImg('others/cloudsample/dialog/copy_btn.png')"
        @click.stop="onCopy"
      ></image>
    </view>
  </view>
</template>

<style lang="scss" scoped>
.result-modal {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  z-index: 99;
  &::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, .6);
    z-index: -1;
  }
  .dialog-body {
    width: 326px;
    height: 382px;
    position: relative;
    transform: translate(0, -70px);
    .result-image {
      width: 100%;
      height: 100%;
    }
    .back-btn {
      width: 169px;
      height: 46px;
      position: absolute;
      top: 307px;
      right: 79px;
    }
  }
}
</style>
